Skip to content

fix(api): warn when the deployed schema does not match schema.prisma - #88

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
lewis/schema-drift-check
Open

fix(api): warn when the deployed schema does not match schema.prisma#88
github-actions[bot] wants to merge 1 commit into
mainfrom
lewis/schema-drift-check

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Opened automatically when lewis/schema-drift-check was pushed.

The title is written from the diff and rewritten as you push, because this is squashed onto main and the title becomes the commit subject and the changelog line. Retitle it yourself and it is yours — the automation stops touching it.

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crm-agent Ready Ready Preview Aug 7, 2026 7:37pm
crm-api Ready Ready Preview Aug 7, 2026 7:37pm
crm-app Ready Ready Preview Aug 7, 2026 7:37pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/setup.md">

<violation number="1" location="docs/setup.md:134">
P3: The reconcile command uses `--to-schema prisma/schema.prisma`, which only resolves when run from inside `packages/db` — the repo root has no `prisma/schema.prisma` and no `prisma.config.ts`, so a self-hoster copying this into the quick-start context (root) gets a schema/file-not-found error. The section never states the working directory. Consider noting that this must be run from `packages/db` (or using the full `packages/db/prisma/schema.prisma` path and the config), so the command is reproducible.</violation>
</file>

<file name="apps/api/scripts/build-func.mjs">

<violation number="1" location="apps/api/scripts/build-func.mjs:197">
P2: The drift diff output is captured with `spawnSync` and all defaults, which caps both stdout and stderr at Node's 1 MiB `maxBuffer`. This check is specifically meant to surface exactly the case where the two schemas disagree — the human-readable summary printed via `drift.stdout` grows with the number of differing tables/columns. If a real drift produces output across the 1 MiB limit, `spawnSync` throws a `RangeError: stdout maxBuffer length exceeded` and the whole build script dies, turning a by-design non-fatal warning into a broken deploy. Consider raising `maxBuffer` (and, optionally, explicitly treating a spawn failure so it still only warns).</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

console.log("✓ migrations applied");

console.log("• checking the deployed schema against schema.prisma...");
const drift = spawnSync(

@cubic-dev-ai cubic-dev-ai Bot Aug 7, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The drift diff output is captured with spawnSync and all defaults, which caps both stdout and stderr at Node's 1 MiB maxBuffer. This check is specifically meant to surface exactly the case where the two schemas disagree — the human-readable summary printed via drift.stdout grows with the number of differing tables/columns. If a real drift produces output across the 1 MiB limit, spawnSync throws a RangeError: stdout maxBuffer length exceeded and the whole build script dies, turning a by-design non-fatal warning into a broken deploy. Consider raising maxBuffer (and, optionally, explicitly treating a spawn failure so it still only warns).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/api/scripts/build-func.mjs, line 197:

<comment>The drift diff output is captured with `spawnSync` and all defaults, which caps both stdout and stderr at Node's 1 MiB `maxBuffer`. This check is specifically meant to surface exactly the case where the two schemas disagree — the human-readable summary printed via `drift.stdout` grows with the number of differing tables/columns. If a real drift produces output across the 1 MiB limit, `spawnSync` throws a `RangeError: stdout maxBuffer length exceeded` and the whole build script dies, turning a by-design non-fatal warning into a broken deploy. Consider raising `maxBuffer` (and, optionally, explicitly treating a spawn failure so it still only warns).</comment>

<file context>
@@ -182,11 +182,52 @@ if (!process.env.VERCEL) {
 	console.log("✓ migrations applied");
+
+	console.log("• checking the deployed schema against schema.prisma...");
+	const drift = spawnSync(
+		bun,
+		[
</file context>
Fix with cubic

Comment thread docs/setup.md
Reconciling is one command, and it is worth reading before running:

```sh
DATABASE_URL="…" bunx prisma migrate diff \

@cubic-dev-ai cubic-dev-ai Bot Aug 7, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The reconcile command uses --to-schema prisma/schema.prisma, which only resolves when run from inside packages/db — the repo root has no prisma/schema.prisma and no prisma.config.ts, so a self-hoster copying this into the quick-start context (root) gets a schema/file-not-found error. The section never states the working directory. Consider noting that this must be run from packages/db (or using the full packages/db/prisma/schema.prisma path and the config), so the command is reproducible.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/setup.md, line 134:

<comment>The reconcile command uses `--to-schema prisma/schema.prisma`, which only resolves when run from inside `packages/db` — the repo root has no `prisma/schema.prisma` and no `prisma.config.ts`, so a self-hoster copying this into the quick-start context (root) gets a schema/file-not-found error. The section never states the working directory. Consider noting that this must be run from `packages/db` (or using the full `packages/db/prisma/schema.prisma` path and the config), so the command is reproducible.</comment>

<file context>
@@ -113,6 +113,28 @@ builds, and the pages that touch them fail. Test schema changes locally, where
+Reconciling is one command, and it is worth reading before running:
+
+```sh
+DATABASE_URL="…" bunx prisma migrate diff \
+  --from-config-datasource --to-schema prisma/schema.prisma --script
+```
</file context>
Fix with cubic

@github-actions github-actions Bot changed the title fix(api): warn when deployed schema drifts from schema.prisma fix(api): warn when the deployed schema does not match schema.prisma Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant